package main

import (
	"github.com/labstack/echo/v4"
	"github.com/labstack/echo/v4/middleware"
	"net/url"
)

// Proxy 提供 HTTP / WebSocket 反向代理中间件。它使用已配置的负载平衡技术将请求转发到上游服务器。
func main() {

	urlOne, _ := url.Parse("http://localhost:8081")
	urlTwo, _ := url.Parse("http://localhost:8082")

	e := echo.New()
	e.Use(middleware.Logger())
	e.Use(middleware.Proxy(middleware.NewRoundRobinBalancer([]*middleware.ProxyTarget{
		{
			URL: urlOne,
		},
		{
			URL: urlTwo,
		},
	})))

	e.Start(":8080")

}
